package com.xu.sys.service.impl;

import com.xu.sys.bean.SysMenu;
import com.xu.sys.bean.SysRole;
import com.xu.sys.bean.SysUser;
import com.xu.sys.dao.IMenuDao;
import com.xu.sys.dao.IRoleDao;
import com.xu.sys.dao.impl.MenuDaoimpl;
import com.xu.sys.dao.impl.RoleDaoImpl;
import com.xu.sys.service.IMenuService;
import com.xu.sys.service.IRoleService;
import com.xu.sys.service.IUserService;
import com.xu.sys.utils.PageUtils;

import java.util.List;

public class MenuServiceimpl implements IMenuService {
    private IMenuDao dao = new MenuDaoimpl();
    private IUserService UserService = new IUserServiceimpl();
    @Override
    public List<SysMenu> list(SysMenu entity) {
        return dao.list(entity);
    }

    @Override
    public int save(SysMenu entity) {
        return dao.save(entity);
    }

    @Override
    public SysMenu findById(int id) {
        return dao.findById(id);
    }

    @Override
    public int updteById(SysMenu entity) {
        return dao.updteById(entity);
    }

    @Override
    public int deleteById(int id) {
        return dao.deleteById(id);
    }

    @Override
    public void listPage(PageUtils pageUtils) {
        //查询分页的数据
        List<SysMenu> list = dao.listPage(pageUtils);
        int count = dao.count(pageUtils);
        // 封装分页的数据
        pageUtils.setList(list);
        pageUtils.setTotalCount(count);
    }

    @Override
    public int count(PageUtils pageUtils) {
        return dao.count(pageUtils);
    }

    @Override
    public List<SysMenu> getAllParent() {
        return dao.getAllParent();
    }

    @Override
    public boolean isDispatcher(int id) {
        return dao.isDispatcher(id);
    }

    @Override
    public boolean havaSubMenu(int id) {
        return !dao.havaSubMenu(id);
    }

    @Override
    public List<SysMenu> findByRoleId(Integer roleId) {
        return dao.findByRoleId(roleId);
    }


}
